<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <script type="application/javascript" src="/static/js/common.js"></script>
    <title>新增/编辑公司账单</title>
</head>
<body>
<div class="app-panel">
    <div class="app-form">
        <form class="layui-form" lay-filter="_form_filter">
            <div class="layui-form-item">
                <label class="layui-form-label">公司名称</label>
                <div class="layui-input-block">
                    <input type="hidden" name="companyUuid">
                    <input type="text" name="companyName" class="layui-input layui-disabled" disabled>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">账目类型</label>
                <div class="layui-input-block">
                    <select name="amountTypeCode" lay-filter="_amountType">
                        <option value="income">入账</option>
                        <option value="receivable">回款</option>
                        <option value="poundage">手续费</option>
                        <option value="shipping">配送费</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">金额</label>
                <div class="layui-input-block">
                    <input type="number" name="amount" class="layui-input" min="0.00" step="0.01">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea name="remark" class="layui-textarea"></textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">

    layui.use(['form','utils', 'axiosUtil'], function () {
        var $ = layui.$,
            layer = parent.layer,
            utils = layui.utils,
            form = layui.form,
        axiosUtil = layui.axiosUtil;

        var uuid = utils.requestParam("uuid");

        //验证公司信息
        axiosUtil.axios_get("/company/delivery/name", {uuid: uuid}, function (companyName) {
            if(companyName){
                $("input[name='companyUuid']").val(uuid);
                $("input[name='companyName']").val(companyName);
            }else {
                layer.alert("公司信息验证失败！", function (index) {
                    layer.close(index);
                    parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭自身iframe
                });
            }
        });

        //监听 账目类型 选择
        form.on('select(_amountType)', function(data){
            let val = data.value, _orderUuid = $("#_orderUuid");

            switch (val) {
                case 'income'://入账
                case 'receivable': //回款


                    break;
                case 'poundage': //手续费
                case 'shipping': //配送费


                    break;
                case 'spending'://支出


                    break;
            }

        });

    })
</script>
</body>
</html>
